<template>
  <div class="car">
    <van-button class="editbtn" @click="editBtn" type="info">编辑地址</van-button>
    <van-divider>商品</van-divider>
    <van-list>
      <van-cell v-for="(item,index) in goodsList" :key="index">
        <van-card :price="item.price" :desc="item.name" :thumb="item.url" />
      </van-cell>
    </van-list>
    <van-submit-bar class="sub_bar" :price="price" button-text="提交订单" @submit="onSubmit" />
  </div>
</template>

<script>
export default {
  name: 'car',
  data () {
    return {
      goodsList: [],
      price: 0
    }
  },
  methods: {
    editBtn () {
      this.$router.push('/address')
    },
    onSubmit () {
      console.log('提交')
    }
  },
  created () {
    this.goodsList = [{
      name: '测试产品',
      url: 'http://image1.suning.cn/uimg/b2c/newcatentries/0000000000-000000000160455569_2_400x400.jpg',
      price: 20

    },
    {
      name: '测试产品2',
      url: 'http://image1.suning.cn/uimg/b2c/newcatentries/0000000000-000000000160455569_2_400x400.jpg',
      price: 20

    }]
    this.goodsList.some(v => {
      this.price += v.price * 100
    })

    console.log(this.price)
  }

}
</script>

<style lang="less" scope>
.editbtn {
  width: 80%;
  position: relative;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 20px;
}
.sub_bar {
  bottom: 50px !important;
}
</style>
